package com.example.mapp.buildSql;

import com.example.entity.MaintenancePlan;
import org.apache.ibatis.jdbc.SQL;

public class MaintenancePlanMappSql {

    public String queryList(MaintenancePlan maintenancePlan){

        String select = " * ";
        String table =" maintenance_plan " ;
        String whereParam="";

        String where = " party_id='"+maintenancePlan.getPartyId()+"' ";

        if(maintenancePlan.getStartDate()!=null){
            maintenancePlan.setStartDate(maintenancePlan.getStartDate()+"%");
            whereParam+=" and start_date like #{startDate} ";
        }
        if (maintenancePlan.getDiscription() != null) {
            maintenancePlan.setDiscription("%" + maintenancePlan.getDiscription() + "%");
            whereParam += " and discription like #{discription} ";
        }
        where = where + whereParam;

        return "select * from" + table +"where"+ where;
    }
}
